﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

using AttributeRouting;
using AttributeRouting.Web.Mvc;
using PH.Model.Schools;
using PH.Logic.Schools;
namespace PH.Web.Management.Areas.School.Controllers
{
    [RouteArea("School")]
    [RoutePrefix("Teacher")]
    [Authorize]
    public class TeacherController : Controller
    {
        [Route("")]
        [Filters.CurrentSchool]
        public ActionResult Index()
        {
            return View();
        }

        [Route("Edit/{schGuid:guid}/{guid:guid?}")]
        public ActionResult Edit(Guid schGuid, Guid? guid)
        {
            TeacherModel model = null;
            var school = SchoolLogic.GetSchool(schGuid);
            if (school != null)
            {
                if (guid != null)
                    model = TeacherLogic.GetTeacher(guid.Value);
                else
                    model = new TeacherModel() { SchoolID = school.ID };
                return PartialView(model);
            }
            else
                throw new HttpException("无效的学校编号");
        }
    }
}
